<?php

/**
 * PagePlan form base class.
 *
 * @method PagePlan getObject() Returns the current form's model object
 *
 * @package    faceshop
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePagePlanForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'page_id'                    => new sfWidgetFormInputHidden(),
      'plan_id'                    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plan'), 'add_empty' => false)),
      'next_plan_id'               => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('NextPlan'), 'add_empty' => true)),
      'extra_credit'               => new sfWidgetFormInputText(),
      'expires_at'                 => new sfWidgetFormDateTime(),
      'offer_id'                   => new sfWidgetFormInputText(),
      'card_id'                    => new sfWidgetFormInputText(),
      'card_expiration'            => new sfWidgetFormDateTime(),
      'card_expiration_email_sent' => new sfWidgetFormInputText(),
      'is_paypal'                  => new sfWidgetFormInputCheckbox(),
      'created_at'                 => new sfWidgetFormDateTime(),
      'updated_at'                 => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'page_id'                    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('page_id')), 'empty_value' => $this->getObject()->get('page_id'), 'required' => false)),
      'plan_id'                    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plan'))),
      'next_plan_id'               => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('NextPlan'), 'required' => false)),
      'extra_credit'               => new sfValidatorInteger(array('required' => false)),
      'expires_at'                 => new sfValidatorDateTime(array('required' => false)),
      'offer_id'                   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'card_id'                    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'card_expiration'            => new sfValidatorDateTime(array('required' => false)),
      'card_expiration_email_sent' => new sfValidatorInteger(array('required' => false)),
      'is_paypal'                  => new sfValidatorBoolean(array('required' => false)),
      'created_at'                 => new sfValidatorDateTime(),
      'updated_at'                 => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('page_plan[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'PagePlan';
  }

}
